package com.xvyy.tingshu.account.service;

import com.xvyy.tingshu.common.result.Result;
import com.xvyy.tingshu.model.account.RechargeInfo;
import com.xvyy.tingshu.model.account.UserAccount;
import com.xvyy.tingshu.model.account.UserAccountDetail;
import com.xvyy.tingshu.vo.account.AccountLockResultVo;
import com.xvyy.tingshu.vo.account.AccountLockVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;

import java.math.BigDecimal;

public interface UserAccountService extends IService<UserAccount> {

    /**
     * 检查账户余额并锁定
     * @param accountLockVo
     * @return
     */
    Result<AccountLockResultVo> checkAndLockAccount(AccountLockVo accountLockVo);

    /**
     * 记录流水
     * @param userId
     * @param title
     * @param tradeType
     * @param amount
     * @param orderNo
     */
    void log(Long userId, String title, String tradeType, BigDecimal amount, String orderNo);

    /**
     * 获取可用余额
     * @return
     */
    BigDecimal getAvailableAmount();

    /**
     * 根据订单编号查询充值业务
     * @param orderNo
     * @return
     */
    RechargeInfo getRechargeInfoByOrder(String orderNo);

    /**
     * 分页查询消费记录
     * @param iPage
     * @return
     */
    IPage<UserAccountDetail> findUserConsumePage(IPage<UserAccountDetail> iPage);

    /**
     * 分页查询充值记录
     * @param iPage
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserRechargePage(IPage<UserAccountDetail> iPage, Long userId);
}
